home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Clock / Sources / View.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.2 KB  |  185 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //
  3. //    File:                View.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef VIEW_H
  11. #define VIEW_H
  12.  
  13. #ifndef FWFRAME_H
  14. #include "FWFrame.h"
  15. #endif
  16.  
  17. #ifndef FWSTRING_H
  18. #include "FWString.h"
  19. #endif
  20.  
  21. #ifndef FWFONT_H
  22. #include "FWFont.h"
  23. #endif
  24.  
  25. #ifndef FWRECT_H
  26. #include "FWRect.h"
  27. #endif
  28.  
  29. #ifndef FWMAPING_H
  30. #include "FWMaping.h"
  31. #endif
  32.  
  33. #ifndef FWTIME_H
  34. #include "FWTime.h"
  35. #endif
  36.  
  37. //========================================================================================
  38. // Classes used by this interface
  39. //========================================================================================
  40.  
  41. class FW_CTime;
  42. class FW_CGraphicContext;
  43. class CClockFrame;
  44.  
  45. //========================================================================================
  46. // CClockView
  47. //========================================================================================
  48.  
  49. class CClockView : public FW_CView
  50. {
  51. public:
  52.     FW_DECLARE_AUTO(CClockView)
  53.     FW_DECLARE_CLASS
  54.  
  55. //----------------------------------------------------------------------------------------
  56. //    Constructor/Destructor
  57. //
  58. public:
  59.     CClockView(Environment* ev);
  60.     virtual ~ CClockView();
  61.  
  62. //----------------------------------------------------------------------------------------
  63. //    Inherited API from FW_CView
  64. //
  65. public:
  66.     virtual void        PostCreateViewFromStream(Environment *ev);
  67.  
  68. //----------------------------------------------------------------------------------------
  69. //    New API
  70. //
  71. public:
  72.     void                 UpdateClock(Environment* ev, const FW_CTime& time);
  73.     
  74.     virtual ODShape*    CreateUsedShape(Environment* ev, const FW_CRect& suggestedUsedRect) = 0;
  75.  
  76. //----------------------------------------------------------------------------------------
  77. //    Data Members
  78. //
  79. protected:
  80.     CClockFrame*        fClockFrame;
  81.     FW_CTime            fLastTime;
  82. };
  83.  
  84. //========================================================================================
  85. // CAnalogView
  86. //========================================================================================
  87.  
  88. class CAnalogView : public CClockView
  89. {
  90. public:
  91.     FW_DECLARE_AUTO(CAnalogView)
  92.     FW_DECLARE_CLASS
  93.  
  94. //----------------------------------------------------------------------------------------
  95. //    Constructor/Destructor
  96. //
  97. public:
  98.     CAnalogView(Environment* ev);
  99.     virtual ~ CAnalogView();
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    Inherited API from FW_CView
  103. //
  104. public:
  105.     virtual void         Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape);    
  106.  
  107. //----------------------------------------------------------------------------------------
  108. //    Inherited API from CClockView
  109. //
  110. public:
  111.     virtual ODShape*    CreateUsedShape(Environment* ev, const FW_CRect& suggestedUsedRect);
  112.         
  113. //----------------------------------------------------------------------------------------
  114. //    New API
  115. //
  116. private:
  117.     void                 DrawClockFace(Environment* ev, FW_CGraphicContext* gc);
  118.     void                 DrawHourHand(Environment* ev, FW_CGraphicContext* gc, FW_Fixed hour, FW_Fixed minute);
  119.     void                 DrawMinuteHand(Environment* ev, FW_CGraphicContext* gc, FW_Fixed minute);
  120.     void                 DrawSecondHand(Environment* ev, FW_CGraphicContext* gc, FW_Fixed second);
  121.  
  122.     void                 DoUpdateClockFacet(Environment* ev, 
  123.                                         FW_CGraphicContext* gc, 
  124.                                         const FW_CRect& clockRect, 
  125.                                         const FW_CTime& newTime);
  126.  
  127. public:
  128.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  129.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  130.     
  131. };
  132.  
  133. //========================================================================================
  134. // CDigitalView
  135. //========================================================================================
  136.  
  137. class CDigitalView : public CClockView
  138. {
  139. public:
  140.     FW_DECLARE_AUTO(CDigitalView)
  141.     FW_DECLARE_CLASS
  142.  
  143. //----------------------------------------------------------------------------------------
  144. //    Constructor/Destructor
  145. //
  146. public:
  147.     CDigitalView(Environment* ev);
  148.     virtual ~ CDigitalView();
  149.  
  150. //----------------------------------------------------------------------------------------
  151. //    Inherited API from FW_CView
  152. //
  153. public:
  154.     virtual void         Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape);    
  155.     
  156. //----------------------------------------------------------------------------------------
  157. //    Inherited API from CClockView
  158. //
  159. public:
  160.     virtual ODShape*    CreateUsedShape(Environment* ev, const FW_CRect& suggestedUsedRect);
  161.     
  162. //----------------------------------------------------------------------------------------
  163. //    New API
  164. //
  165. private:
  166.     FW_CRect            GetDigitalClockRect(Environment* ev, const FW_CRect& suggestedUsedRect);
  167.  
  168.             void         DoUpdateClockFacet(Environment* ev, 
  169.                                         FW_CGraphicContext* gc, 
  170.                                         const FW_CRect& clockRect, 
  171.                                         const FW_CTime& newTime);
  172.  
  173. public:
  174.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  175.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  176.  
  177. //----------------------------------------------------------------------------------------
  178. //    Data Members
  179. //
  180. private:
  181.     FW_CFont            fFont;
  182. };
  183.  
  184. #endif
  185.